class Tournament < ActiveRecord::Base
  validates_presence_of :title
  validates_presence_of :start_date
  validates_presence_of :end_date
  validates_presence_of :coefficient01
  
  has_many :user_tournaments, :dependent => :destroy
  has_many :users, :through => :user_tournaments
  
  before_save :validate_start_end_date
  
  def validate_start_end_date
    return false if self.end_date < self.start_date
    return true
  end

end
